#include<iostream>
using namespace std;
int num=0;
struct node{
    int data;
    node * next;
    node():next(nullptr){}
};
int main(){
    int n;
    cin>>n;
    num=n;
    node * head=new node();
    node * now;
    now=head;
    for(int i=1;i<=n;i++){
        int x;
        node * newnode=new node();
        cin>>x;
        newnode->data=x;
        now->next=newnode;
        now=now->next;
    }
    int m;
    cin>>m;
    int a;
    int k;
    for(int i=1;i<=m;i++){
    cin>>a;
    cin>>k;
    if(a){
        if(k>num||k==0)continue;
        else {
            now=head;
            int js=0;
            while(js<k-1){
                now=now->next;
                js++;
            }
            now->next=now->next->next;
            num--;
        }
      }
      else {
        now=head;
        int c;
        cin>>c;
        if(k>num)continue;
        int js=0;
         while(js<k){
                now=now->next;
                js++;
            }
        node * f=new node();
        f->data=c;
        f->next=now->next;
        now->next=f;
        num++;
        
      }
    }
    now=head;
    for(int i=1;i<=num;i++){
        node * yl;
        yl=now;
        now=now->next;
        cout<<now->data<<' ';
        delete yl;
    }
    return 0;
}